import bisect

n, m = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
pos = bisect.bisect_left(nums, 0)
ans = float('inf')
for j in range(m + 1):
    if pos - j < 0 or pos + m - j - 1 >= n: continue
    cl = abs(nums[pos - j])
    if j == 0: cl = 0
    cr = abs(nums[pos + m - j - 1])
    if j == m: cr = 0
    ans = min(ans, min(2 * cl + cr, 2 * cr + cl))
print(ans)
